from django.http import HttpResponse


class OnlyChrome:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        # Code to be executed for each request before
        # the view (and later middleware) are called.
        if 'chrome' not in request.headers['User-Agent'].lower():
            return HttpResponse('请使用chrome类浏览器访问')

        response = self.get_response(request)

        # Code to be executed for each request/response after
        # the view is called.

        return response